#include "BaseMath.h"

#include "math.h"

namespace GxLibBasic
{
	Int Round(double f)
	{
		Int itf = (Int)f;
		if (f-itf<0.5)
			return itf;
		else
			return itf+1;
	}

	Int Trunc(double f)
	{
		return (Int)f;
	}

	Int Ceil(double f)
	{
		Int itf = (Int)f;
		if (f-itf>1e-5)
			return itf+1;
		else
			return itf;
	}

	int GetPO2Value(int v)
	{
		static double log2 = log(2.0);
		int exponent = (int)ceil(log((double)v)/log2);
		return 1<<exponent;
	}

}